_posts/2017-5-16-Connecting existing Web App to Azure database for MySQL (Preview).html (38 lines of code) (raw):

--- title: "Connecting existing Web App to Azure Database for MySQL (Preview)" hide_excerpt: true --- <html><head> <meta charset="utf-8"/> </head> <body> <div id="page"> <a class="url fn n profile-usercard-hover" href="https://social.msdn.microsoft.com/profile/mksunitha" target="_blank">mksunitha</a> <time> 5/16/2017 9:11:12 AM</time> <hr/> <div id="content">The following steps show how to connect your existing web app on Azure App Service running on MySQL in-app or other MySQL solutions in Azure to <a href="https://azure.microsoft.com/en-us/services/mysql/">Azure database for MySQL (Preview)</a>. <h2>Before your begin</h2> Log in to the <a href="https://porta.azure.com">Azure portal</a> . Create a MySQL database on Azure Database for MySQL (Preview) service . For details , refer to <a href="https://docs.microsoft.com/en-us/azure/mysql/quickstart-create-mysql-server-database-using-azure-portal">How to create MySQL database from Portal</a> or <a href="https://docs.microsoft.com/en-us/azure/mysql/quickstart-create-mysql-server-database-using-azure-cli">How to create MySQL database using CLI.</a> <h2 id="firewall">Firewall configuration</h2> Azure database for MySQL provides tighter security using Firewall to protect your data. When using this service with App Service Web Apps , you need to keep in mind that the outbound IPs are dynamic in nature . <ol> <li>To make sure the availability of your web app is not compromised , we recommend to all the rule to allow ALL IPs as shown in the image below.  <strong>Note: </strong><em>We are working with Azure database for MySQL (Preview) team for a long term solution to avoid allowing all IPs.  </em><img alt="allowallrule" class="alignnone wp-image-4805" height="214" src="{{ site.baseurl }}/media/2017/05/allowallrule-1024x378.png" width="579"/></li> <li>You can explicitly add all the outbound IPs for your web app to MySQL server configuration . To learn more , see <a href="https://blogs.msdn.microsoft.com/waws/2017/02/01/how-do-i-determine-the-outbound-ip-addresses-of-my-azure-app-service/">how to get outbound IPs for App Service</a>.<a href="{{ site.baseurl }}/media/2017/05/outboundip.png"><img alt="outboundip" class="alignnone wp-image-4797" height="110" src="{{ site.baseurl }}/media/2017/05/outboundip.png" width="374"/></a></li> </ol> <div>App service infrastructure tries to  keep the outbound IPs the same as best as we can , but when recycle or scale operation occurs  it may change since we add new machines on every region frequently to increase our capacity to server customers.  If this changes , the app will experience downtime since it can no longer connect to the database.   Keep this mind when choosing one of the option mentioned above.</div> <h2 id="ssl">SSL configuration</h2> Azure database for MySQL (Preview) has SSL <strong>Enabled</strong> . If your application is not using SSL to connect to the database , then you need to <strong>Disable</strong> SSL on MySQL server. For details on how to configure SSL , See <a href="https://blogs.msdn.microsoft.com/appserviceteam/2017/05/10/connect-azure-app-service-to-azure-database-for-mysql-and-postgresql-via-ssl/">using SSL with Azure database for MySQL (Preview)</a>. <img alt="ssldisable" class="alignnone size-large wp-image-4806" height="216" src="{{ site.baseurl }}/media/2017/05/ssldisable-1024x252.png" width="879"/> Note that some applications frameworks may not support SSL , hence check your application framework documentation on whether to disable or enable SSL. <h2 id="mysqlinapp">Migrating from MySQL in-app database to Azure Database for MySQL (Preview)</h2> You can migrate MySQL in-app database to Azure database for MySQL (Preview) using <a href="https://blogs.msdn.microsoft.com/appserviceteam/2017/03/06/migrate-development-database-on-mysql-in-app-to-production-mysql-database/">Export feature</a>. Note in order to use this feature to export the database , you need to : <ul> <li>Disable SSL since the feature does not work with MySQL database connected via SSL.</li> <li>Allow all IPs is configured on your MySQL server</li> </ul> <h2>App Service Back up and Restore features</h2> Currently backup and restore feature does not work with SSL enabled for Azure Database for MySQL (Preview). Disable SSL if you are planning to backup/restore the database using App service backup feature . Azure database for MySQL (Preview) also offers backup feature , for more details see <a href="https://docs.microsoft.com/en-us/azure/mysql/howto-restore-server-portal">here</a>.</div> </div></body> <script src="{{ site.baseurl }}/resource/jquery-1.12.1.min.js" type="text/javascript"></script> <script src="{{ site.baseurl }}/resource/replace.js" type="text/javascript"></script> </html>